package com.ruoyi.quartz.util;


import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.sql.Time;
import java.util.*;
import java.util.List;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.quartz.task.RyTask;
import com.ruoyi.system.domain.AdminLuckyCommand;
import gui.ava.html.Html2Image;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.imageio.ImageIO;
import javax.swing.*;

public class TestTable2 {

    private static final Logger logger = LoggerFactory.getLogger(TestTable2.class);
    private static String getSingleImageHtml(String title, List<String> headTitle, List<List<String>> contentArray) {
        String html ="<html>\n" +
                "<head>\n" +
                "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"+
                "</head>\n" +
                "<body style=\"width: 1100px;\">\n" +
                "    <table style=\";border-collapse:collapse;\">\n" +
                "        <tr style=\"background-color:#f5f5f5\">\n" +
                "            <td style=\"text-align: center;padding: 10px;border-color:rgb(60,182,231);width: 200px;font-size:32px;\">开奖时间</td>\n" +
                "            <td style=\"text-align: center;padding: 10px;border-color:rgb(60,182,231);width: 200px;font-size:32px;\">期数</td>\n" +
                "            <td style=\"text-align: center;padding: 10px;border-color:rgb(60,182,231);width: 700px;font-size:32px;\">开奖号码</td>\n" +
                "        </tr>\n" ;

                    for (int i=0;i<contentArray.size();i++) {
                        if(i%2==0){
                            html +="<tr style=\"background: url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/88fbfade-5023-4668-a3ca-b22c17c8bf79.png');"+(i==0? "border: 3px solid red;": "")+"\">\n" ;
                        }else{
                            html +="<tr>\n" ;
                        }
                        for (int j = 0; j < 3; j++) {
                            String tdEle = "";
                            if (j < 2) {
                                tdEle = "<td style=\"text-align: center;padding: 10px;width: 200px;font-size:32px;\">" + contentArray.get(i).get(j) + "</td>";
                            } else {
                                tdEle = "<td style=\"display: flex;justify-content: space-around;text-align: center;padding: 10px;width: 700px;\">";
                                String numbers = contentArray.get(i).get(j);
                                String[] ss =numbers.split(",");
                                for(String s :ss){
                                    if(Integer.parseInt(s)%2 ==0){
                                        tdEle += "                <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/045b5b59-4b0b-4a51-ab64-00808154dd34.png');text-align: center;display: inline-block;width: 60px;line-height: 60px;height: 60px;color:#fff;margin:0px 4px;font-size:32px;\">"+s+"</span>\n";
                                    }else{
                                        tdEle += "                <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3e601e4c-108f-4754-9b42-77feb6db2dba.png');text-align: center;display: inline-block;width: 60px;line-height: 60px;height: 60px;color:#fff;margin:0px 4px;font-size:32px;\">"+s+"</span>\n";
                                    }

                                }
                                tdEle += "</td>";
                            }
                            html += tdEle;
                        }
                        html +=  "        </tr>\n" ;
                    }
        html +="    </table>\n" +
                "</body>\n" +
                "\n" +
                "</html>";
        return html;
    }

    private static String getTwoImageHtml(String title, List<String> headTitle, List<List<String>> contentArray,Integer[] result) {
        String html ="<html>\n" +
                "<head>\n" +
                "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"+
                "</head>\n" +
                "<body style=\"width: 1450px;\">\n" +
                "    <table style=\";border-collapse:collapse;\">\n" +
                "        <tr style=\"background-color:rgb(55,182,229)\">\n" +
                "            <td style=\"text-align: center;padding: 10px;border-color:rgb(60,182,231);width: 150px;font-size:62px;color:white;font-weight:1600;\">期数</td>\n" +
                "            <td style=\"text-align: center;padding: 10px;border-color:rgb(60,182,231);width: 150px;font-size:62px;color:white;font-weight:1600;\">时间</td>\n" +
                "            <td style=\"text-align: center;padding: 10px;border-color:rgb(60,182,231);width: 800px;font-size:62px;color:white;font-weight:1600;\">结果</td>\n" +
                "            <td style=\"text-align: left;padding: 10px;border-color:rgb(60,182,231);width: 300px;font-size:62px;color:white;font-weight:1600;\">番</td>\n" +
                "        </tr>\n" ;

        for (int i=0;i<contentArray.size();i++) {
            if (i==0) {
                html +="<tr style=\"border:10px solid red;\">\n" ;
            }else{
                html +="<tr>\n" ;
            }
            for (int j = 0; j < 4; j++) {
                String tdEle = "";
                if (j < 2) {
                    if (i==0) {
                        if (j==0) {
                            tdEle = "<td style=\"text-align: center;border-top:3px solid red;border-bottom:3px solid red;border-left:3px solid red;padding: 5px;width: 150px;font-size:55px;\">" + contentArray.get(i).get(j) + "</td>";
                        }else{
                            tdEle = "<td style=\"text-align: center;border-top:3px solid red;border-bottom:3px solid red;padding: 5px;width: 150px;font-size:55px;\">" + contentArray.get(i).get(j) + "</td>";
                        }
                    }else{
                        tdEle = "<td style=\"text-align: center;padding: 5px;width: 150px;font-size:55px;\">" + contentArray.get(i).get(j) + "</td>";
                    }


                } else if (j==2){
                    if (i==0) {
                        tdEle = "<td style=\"display: flex;justify-content: space-around;border-top:3px solid red;border-bottom:3px solid red;text-align: center;font-weight:normal;padding: 5px;width: 800px;\">";
                    }else{
                        tdEle = "<td style=\"display: flex;justify-content: space-around;text-align: center;font-weight:normal;padding: 5px;width: 800px;\">";
                    }
                    String numbers = contentArray.get(i).get(j);
                    String[] ss =numbers.split(",");

                    for(int f=0;f<ss.length;f++){
                        if(f==7){
                            tdEle += "                <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/bda9a1f1-4f75-46b1-ab6c-07d23748ec93.png');text-align: center;display: inline-block;width: 75.5px;line-height: 76px;height: 76px;margin-right:2px;font-size:55px;\">"+ss[f]+"</span>\n";
                        }else{
                            tdEle += "                <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');text-align: center;display: inline-block;width: 75px;line-height: 76px;height: 76px;margin-right:2px;font-size:55px;\">"+ss[f]+"</span>\n";
                        }

                    }
                    tdEle += "</td>";
                }else {
                    if (i==0) {
                        tdEle = "<td style=\"display: flex;border-top:3px solid red;border-bottom:3px solid red;border-right:3px solid red;justify-content: space-around;text-align: left;padding: 10px;width: 200px;\">";
                    }else{
                        tdEle = "<td style=\"display: flex;justify-content: space-around;text-align: left;padding: 10px;width: 200px;\">";
                    }
                    String numbers = contentArray.get(i).get(j);
                    String[] ss =numbers.split(",");

                    for(int f=0;f<ss.length;f++){
                        if(f==0){
                            if (Integer.valueOf(ss[f])==1) {
                                tdEle += "                <span style=\"border-radius:50%;background:#5d96ff;display: inline-block;text-align: center;width: 76px;line-height: 76px;height:76px;color:#fff;text-align:center;margin-top:3px; font-weight:600;font-size:55px;\">"+ss[f]+"</span>\n";
                            }else if (Integer.valueOf(ss[f])==2) {
                                tdEle += "                <span style=\"border-radius:50%;background:#3ec67c;display: inline-block;text-align: center;width: 76px;line-height: 76px;height: 76px;color:#fff;text-align:center;margin-top:3px; font-weight:600;font-size:55px;\">"+ss[f]+"</span>\n";
                            }else if (Integer.valueOf(ss[f])==3) {
                                tdEle += "                <span style=\"border-radius:50%;background:#f7d400;display: inline-block;text-align: center;width: 76px;line-height: 76px;height: 76px;color:#fff;text-align:center;margin-top:3px; font-weight:600;font-size:55px;\">"+ss[f]+"</span>\n";
                            }else {
                                tdEle += "                <span style=\"border-radius:50%;background:#ff3e41;display: inline-block;text-align: center;width: 76px;line-height: 76px;height: 76px;color:#fff;text-align:center;margin-top:3px; font-weight:600;font-size:55px;\">"+ss[f]+"</span>\n";
                            }

                        }else if(f==1) {
                            tdEle += "                <span style=\"background:white;display: inline-block;width: 60px;line-height: text-align: center;60px;height: 60px;margin-top:3px;margin-left:20px;font-weight:600;font-size:55px;\">"+ss[f]+"</span>\n";
                        }else{
                            tdEle += "                <span style=\"background:white;display: inline-block;width: 60px;line-height: text-align: center;60px;height: 60px;margin-top:3px;font-weight:600;font-size:55px;\">"+ss[f]+"</span>\n";
                        }


                    }
                    tdEle += "</td>";
                }

                html += tdEle;
            }
            html +=  "        </tr>\n" ;

        }
        int index=0;
        for (int l=0;l<6;l++){
            html +="    </table>\n";
            html +="    <table style=\"border-collapse:collapse;\">\n";
            if (l==0) {
                html +="<tr style=\"background:rgb(210,210,210);height:105px!important;\">\n" ;
            }else{
                html +="<tr style=\"height:105px!important;\">\n" ;
            }

            for (int h=0;h<13;h++) {
                if (l==0) {
                    if (h==5) {
                        html += "<td style=\"text-align: center;width: 102px;height:105px!important;border:2px solid rgb(181,181,181);margin:0px!important;font-size:72px;font-weight:5000;\">路";
                    }else if (h==6){
                        html += "<td style=\"text-align: center;width: 102px;height:105px!important;border:2px solid rgb(181,181,181);margin:0px!important;font-size:72px;font-weight:5000;\">子";
                    }else if (h==7){
                        html += "<td style=\"text-align: center;width: 102px;height:105px!important;border:2px solid rgb(181,181,181);margin:0px!important;font-size:72px;font-weight:5000;\">格";
                    }else{
                        html += "<td style=\"text-align: center;width: 102px;height:105px!important;border:2px solid rgb(181,181,181);margin:0px!important\">";
                    }
                }else{
                    html += "<td style=\"text-align: center;width: 102px;height:105px!important;border:2px solid rgb(181,181,181);margin:0px!important\">";
                    if (h<=10){
                        if (result[index]==1) {
                            html += "                <span style=\"border-radius:50%;background:#5d96ff;display: inline-block;text-align: center;width: 90px;line-height: 90px;height: 90px;color:#fff;text-align:margin-top:20px;font-size:68px;font-weight:600;\">"+result[index]+"</span>\n";
                            index++;
                        }else if(result[index]==2){
                            html += "                <span style=\"border-radius:50%;background:#3ec67c;display: inline-block;text-align: center;width: 90px;line-height: 90px;height: 90px;color:#fff;text-align:margin-top:20px;font-size:68px;font-weight:600;\">"+result[index]+"</span>\n";
                            index++;
                        }else if(result[index]==3){
                            html += "                <span style=\"border-radius:50%;background:#f7d400;display: inline-block;text-align: center;width: 90px;line-height: 90px;height: 90px;color:#fff;text-align:margin-top:20px;font-size:68px;font-weight:600;\">"+result[index]+"</span>\n";
                            index++;
                        }else if(result[index]==4){
                            html += "                <span style=\"border-radius:50%;background:#ff3e41;display: inline-block;text-align: center;width: 90px;line-height: 90px;height: 90px;color:#fff;text-align:margin-top:20px;font-size:68px;font-weight:600;\">"+result[index]+"</span>\n";
                            index++;
                        }
                    }
                }

                html += "</td>";
            }
            html +=  "        </tr>\n" ;
        }
        html +="    </table>\n" +
                "</body>\n" +
                "\n" +
                "</html>";
        return html;
    }

    public static String getStartHtml(HashMap hashMap, String[] s) {
        String html ="<html>\n" +
                "<head>\n" +
                "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" +
                "</head>\n" +
                "<body style=\"width: 800px;margin:10px 30px;height:300px\">\n" +
                "      <div > \n" +
                "               <div style=\"float:left\">\n" +
                "\t   <p><i style=\"color:red;font-size: 50px;font-weight: 900;margin-right:35px\">开盘结果</i><i  style=\"font-size: 44px;font-weight: 900;\">"+hashMap.get("period")+"期</i></p>\n" +
                "\n" +
                "\t   <p  style=\"margin-top:30px;\"><i style=\"margin-left:25px;font-size: 44px;font-weight: 700;\">"+hashMap.get("time")+"</i></p>\n" +
                "                   \n" +
                "                </div>\n" +
                "                <div style=\"float:right; width: 200px;height:130px;background: red; display: block;margin-top:25px;margin-right:45px\">\n" +
                "\t      <div style=\"font-size: 80px;text-align:center;line-height:130px;letter-spacing:8px;\n" +
                "                           color: #fff;text-shadow: #d56238 0px 2px,#d56238 2px 0px,#d56238 -2px 0px,#d56238 0px -2px,#d56238 -1.4px -1.4px,#d56238 1.4px 1.4px,#d56238 1.4px -                          1.4px,#d56238 -1.4px 1.4px;\">"+hashMap.get("num")+"番    \n" +
                "                      </div>\n" +
                "                </div>\n" +
                "     </div>\n" +
                "       <div style=\"font-weight: bold;font-size:40px;color:#793301;clear:both;margin-top:35px\">\n" +
                "                         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');display:inline-block;width: 75px;height: 76px;text-align:center;line-height:76px;\">"+s[0]+"</span>\n" +
                "\t         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');display:inline-block;width: 75px;height: 76px;text-align:center;line-height:76px;\">"+s[1]+"</span>\n" +
                "\t         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');display:inline-block;width: 75px;height: 76px;text-align:center;line-height:76px;\">"+s[2]+"</span>\n" +
                "\t         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');display:inline-block;width: 75px;height: 76px;text-align:center;line-height:76px;\">"+s[3]+"</span>\n" +
                "\t         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');display:inline-block;width: 75px;height: 76px;text-align:center;line-height:76px;\">"+s[4]+"</span>\n" +
                "\t         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');display:inline-block;width: 75px;height: 76px;text-align:center;line-height:76px;\">"+s[5]+"</span>\n" +
                "\t         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/3f069f3a-efe1-485c-a824-af54ec1ece8e.png');display:inline-block;width: 75px;height: 76px;text-align:center;line-height:76px;\">"+s[6]+"</span>\n" +
                "\t         <span style=\"background:url('http://admin.ballnicethis.xyz/prod-api/profile/upload/2021/08/03/bda9a1f1-4f75-46b1-ab6c-07d23748ec93.png');display:inline-block;width: 76px;height: 76px;text-align:center;line-height:76px;\">"+s[7]+"</span>\n" +
                "                     </div>\n" +
                "    \t\n" +
                "\n" +
                "</body>\n" +
                "</html>";
        return html;
    }

    public static String getStartThree(String s) {
        String html ="<html>\n" +
                "<head>\n" +
                "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" +
                "</head>\n" +
                "<body style=\"width: 800px;margin:10px 30px;font-size:42px;line-height:72px;font-weight:200\">\n" +
                    s+
                "</body>\n" +
                "</html>";
        return html;
    }

    public static String graphicsHtmlGeneration(List<List<List<String>>> allValue, List<String> titles,
                                                List<List<String>> headers) throws Exception {
        int i = 0;
        String html = "";
        for (List<List<String>> list : allValue) {
            String title = titles.get(i);
            List<String> headTitle = headers.get(i);
            html += getSingleImageHtml(title, headTitle, list);
            i++;
        }
        if (html != null && html.length() > 0) {
            Html2Image html2Image = Html2Image.fromHtml(html);
//            String profile = "D:/ruoyi/uploadPath";
            String profile = RuoYiConfig.getProfile();
            String datePath = DateUtils.datePath() ;
            String fileName = IdUtils.fastUUID() + "." + "png";
            String filePath =profile + "/" +datePath;
            if(!new File(filePath).exists())   {
                new File(filePath).mkdirs();
            }
            html2Image.getImageRenderer().saveImage( filePath + "/"  + fileName);
            String prefix = Constants.RESOURCE_PREFIX;
            return prefix + "/" +datePath + "/" +fileName;
/*            HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
            imageGenerator.loadHtml(html);
            try {
//                 Thread.sleep(5000);
                imageGenerator.getBufferedImage();
//                 Thread.sleep(5000);
                String path = "111.png";
                imageGenerator.saveAsImage(path);
                return path;
            } catch (Exception e) {
            }*/
        }
        return null;

    }


    public static String graphicsStart(String html){
        if (html != null && html.length() > 0) {
            Html2Image html2Image = Html2Image.fromHtml(html);
//            String profile = "D:/ruoyi/uploadPath";
            String profile = RuoYiConfig.getProfile();
            String datePath = DateUtils.datePath();
            String fileName = IdUtils.fastUUID() + "." + "png";
            String filePath = profile + "/" + datePath;
            if (!new File(filePath).exists()) {
                new File(filePath).mkdirs();
            }
            html2Image.getImageRenderer().setWidth(800);
            html2Image.getImageRenderer().setHeight(300);
            html2Image.getImageRenderer().saveImage(filePath + "/" + fileName);
            String prefix = Constants.RESOURCE_PREFIX;
            return prefix + "/" + datePath + "/" + fileName;
/*            HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
            imageGenerator.loadHtml(html);
            try {
//                 Thread.sleep(5000);
                imageGenerator.getBufferedImage();
//                 Thread.sleep(5000);
                String path = "111.png";
                imageGenerator.saveAsImage(path);
                return path;
            } catch (Exception e) {
            }*/
        }
        return null;
    }

    public static String graphicsThree(String html){
        html = getStartThree(html);
        if (html != null && html.length() > 0) {
            Html2Image html2Image = Html2Image.fromHtml(html);
//            String profile = "E:/ruoyi/uploadPath";
            String profile = RuoYiConfig.getProfile();
            String datePath = DateUtils.datePath();
            String fileName = IdUtils.fastUUID() + "." + "png";
            String filePath = profile + "/" + datePath;
            if (!new File(filePath).exists()) {
                new File(filePath).mkdirs();
            }
            html2Image.getImageRenderer().setWidth(800);
            html2Image.getImageRenderer().saveImage(filePath + "/" + fileName);
            String prefix = Constants.RESOURCE_PREFIX;
            return prefix + "/" + datePath + "/" + fileName;
/*            HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
            imageGenerator.loadHtml(html);
            try {
//                 Thread.sleep(5000);
                imageGenerator.getBufferedImage();
//                 Thread.sleep(5000);
                String path = "111.png";
                imageGenerator.saveAsImage(path);
                return path;
            } catch (Exception e) {
            }*/
        }
        return null;
    }

    public static String twoHtmlGeneration(List<List<List<String>>> allValue, List<String> titles,
                                                List<List<String>> headers,Integer[] result) throws Exception {
        int i = 0;
        String html = "";
        for (List<List<String>> list : allValue) {
            String title = titles.get(i);
            List<String> headTitle = headers.get(i);
            html += getTwoImageHtml(title, headTitle, list,result);
            i++;
        }
        if (html != null && html.length() > 0) {
            Html2Image html2Image = Html2Image.fromHtml(html);
//            String profile = "E:/ruoyi/uploadPath";
            String profile = RuoYiConfig.getProfile();
            String datePath = DateUtils.datePath() ;
            String fileName = IdUtils.fastUUID() + "." + "png";
            String filePath =profile + "/" +datePath;
            if(!new File(filePath).exists())   {
                new File(filePath).mkdirs();
            }
            html2Image.getImageRenderer().setWidth(1300);
            html2Image.getImageRenderer().saveImage( filePath + "/"  + fileName);
            String prefix = Constants.RESOURCE_PREFIX;
            return prefix + "/" +datePath + "/" +fileName;
/*            HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
            imageGenerator.loadHtml(html);
            try {
//                 Thread.sleep(5000);
                imageGenerator.getBufferedImage();
//                 Thread.sleep(5000);
                String path = "111.png";
                imageGenerator.saveAsImage(path);
                return path;
            } catch (Exception e) {
            }*/
        }
        return null;

    }
    public static void main(String[] args) throws Exception {
        List<String> allValue1 = new ArrayList<String>();
        allValue1.add("20:00");
        allValue1.add("202000121");
        allValue1.add("18,14,12,15,12,03,06,05");
        allValue1.add("4,单,小");
        List<String> allValue3 = new ArrayList<String>();
        allValue3.add("20:00");
        allValue3.add("202000121");
        allValue3.add("18,14,12,15,12,03,06,05");
        allValue3.add("1,单,小");
        List<String> allValue4 = new ArrayList<String>();
        allValue4.add("20:00");
        allValue4.add("202000121");
        allValue4.add("18,14,12,15,12,03,06,05");
        allValue4.add("2,单,小");
        List<List<String>> allValue2 = new ArrayList<>();
        allValue2.add(allValue1);
        allValue2.add(allValue3);
        allValue2.add(allValue4);
        List<List<List<String>>> allValue = new ArrayList<>();
        allValue.add(allValue2);

        List<String> titles = new ArrayList<>();
        titles.add("标题可以识汉字不");
        List<List<String>> headers = new ArrayList<>();
        List<String> header = new ArrayList<>();
        header.add("期数");
        header.add("时间");

        header.add("结果");
        header.add("番");
        headers.add(header);
        Integer[] ints=new Integer[55];
        Random rand = new Random();

//        for (int i=0;i<55;i++) {
//            int i1 = rand.nextInt(4) + 1;
//            ints[i]=i1;
//        }
//        try {
//            String path = twoHtmlGeneration(allValue, titles, headers,ints);
//            System.out.println("path=" + path);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        try {
            HashMap hashMap = new HashMap();
            hashMap.put("time",DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.getNowDate()));
            hashMap.put("period","2822522");
            hashMap.put("num","4");

            String[] strings = new String[]{"01","02","11","13","15","18","20","16",};

            String path = graphicsStart(new TestTable2().getStartHtml(hashMap,strings));
            System.out.println("path=" + path);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        String html="<html>\n" +
//                "               <head>\n" +
//                "               <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" +
//                "               </head>\n" +
//                "               <body style=\"width: 90px;height:90px\">\n" +
//                "                      <div style=\";width: 90px;\n" +
//                "  height: 90px;\n" +
//                "  background: #ffffff;\n" +
//                "  border-radius: 50%;\n" +
//                "  border: 5px solid red;\">\n" +
//                "                      </div>\n" +
//                "               </body>\n" +
//                "</html>";
//        String test = test(html);
//        System.out.println(test);
    }

    public static String test(String html){
        if (html != null && html.length() > 0) {
            Html2Image html2Image = Html2Image.fromHtml(html);
            String profile = "E:/ruoyi/uploadPath";
//            String profile = RuoYiConfig.getProfile();
            String datePath = DateUtils.datePath();
            String fileName = IdUtils.fastUUID() + "." + "png";
            String filePath = profile + "/" + datePath;
            if (!new File(filePath).exists()) {
                new File(filePath).mkdirs();
            }
            html2Image.getImageRenderer().setWidth(90);
            html2Image.getImageRenderer().setHeight(90);
            html2Image.getImageRenderer().saveImage(filePath + "/" + fileName);
            String prefix = Constants.RESOURCE_PREFIX;
            return prefix + "/" + datePath + "/" + fileName;
/*            HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
            imageGenerator.loadHtml(html);
            try {
//                 Thread.sleep(5000);
                imageGenerator.getBufferedImage();
//                 Thread.sleep(5000);
                String path = "111.png";
                imageGenerator.saveAsImage(path);
                return path;
            } catch (Exception e) {
            }*/
        }
        return null;
    }
}